﻿#ifndef COMPANYSERVICE_H
#define COMPANYSERVICE_H

#include <QObject>
#include "companynetworkaccessmanager.h"
#include "company.h"
#include <QPushButton>

class CompanyService : public QObject
{
    Q_OBJECT
public:
    explicit CompanyService(QObject *parent = nullptr);

    void newCompany(QWidget *widget, QString companyName, QString contact);

    void updateCompany(
            QWidget *widget,
            QString companyId,
            QString taxRate,
            QString companyName,
            QString contact,
            QString tel,
            QString fax,
            QString website,
            QString email,
            QString province,
            QString city,
            QString district,
            QString address,
            QString account,
            QString introduction,
            QString ticketCompanyName,
            QString taxNum,
            QString bank,
            QString ticketAccount,
            QString ticketTel,
            QString ticketAddress);

    void queryCompany(QWidget *widget, QString companyId);

    void joinCompany(QWidget *widget, QString companyId);

    void updateCategory(QWidget *widget, Company::CategoryType categoryType, QString productCategory);

    void updateCategory(
            QWidget *widget,
            Company::CategoryType categoryType,
            QString oldPrimaryDirectory,
            QString oldSecondaryDirectory,
            QString newPrimaryDirectory,
            QString newSecondaryDirectory);

    void deleteCategory(
            QWidget *widget,
            Company::CategoryType categoryType,
            QString primaryDirectory,
            QString secondaryDirectory);

    void updateCompanyData(QWidget *widget, bool showMsg);

    void homeCount(QWidget *widget, QPushButton *button, int type, double oldValue, double countValue);
signals:
    void addCompanySuccess();

    void queryCompanySuccess(Company &company);

    void joinCompanySuccess();

    void deleteOK();

    void editOK(QString newCategory);

    void updateCompanyDataSuccess(double totalStore);

public slots:

private:
    CompanyNetworkAccessManager *manager;
};

#endif // COMPANYSERVICE_H
